package dao.impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import dao.AdminDao;
import dao.RowMapper;
import entity.Admin;
//HanMan
public class AdminDaoImpl implements AdminDao {
	JDBCTemplate jdbc = new JDBCTemplate();

	private class rowMapperImpl implements RowMapper<Admin>{
		@Override
		public Admin rowMapper(ResultSet rs) throws SQLException {
			return new Admin(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getDate(4));
		}
	}
	
	
	@Override
	public Admin queryAdmin(String userName, String password) {
		return jdbc.queryOne("select * from admin where username=? and password=?", new rowMapperImpl(),userName,password);
	}
	@Override
	public Admin queryAdminByIdAdminId(int adminId) {
		return jdbc.queryOne("select * from admin where id=?", new rowMapperImpl(), adminId);
	}

}
